home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / fscheck / RCS / fscheck.h,v < prev    next >
Encoding:
Text File  |  1990-11-01  |  14.0 KB  |  694 lines

  1. head     1.17;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.17
  10. date     90.10.10.15.29.07;  author mendel;  state Exp;
  11. branches ;
  12. next     1.16;
  13.  
  14. 1.16
  15. date     90.10.10.11.22.14;  author jhh;  state Exp;
  16. branches ;
  17. next     1.15;
  18.  
  19. 1.15
  20. date     90.05.01.15.36.45;  author jhh;  state Exp;
  21. branches ;
  22. next     1.14;
  23.  
  24. 1.14
  25. date     90.02.14.15.55.32;  author jhh;  state Exp;
  26. branches ;
  27. next     1.13;
  28.  
  29. 1.13
  30. date     89.10.03.11.09.05;  author jhh;  state Exp;
  31. branches ;
  32. next     1.12;
  33.  
  34. 1.12
  35. date     89.09.25.16.41.17;  author jhh;  state Exp;
  36. branches ;
  37. next     1.11;
  38.  
  39. 1.11
  40. date     89.06.21.23.56.07;  author jhh;  state Exp;
  41. branches ;
  42. next     1.10;
  43.  
  44. 1.10
  45. date     89.02.28.12.22.36;  author jhh;  state Exp;
  46. branches ;
  47. next     1.9;
  48.  
  49. 1.9
  50. date     88.12.04.21.34.31;  author nelson;  state Exp;
  51. branches ;
  52. next     1.8;
  53.  
  54. 1.8
  55. date     88.07.19.11.47.51;  author douglis;  state Exp;
  56. branches ;
  57. next     1.7;
  58.  
  59. 1.7
  60. date     88.06.02.13.01.58;  author brent;  state Exp;
  61. branches ;
  62. next     1.6;
  63.  
  64. 1.6
  65. date     88.06.02.12.58.19;  author brent;  state Exp;
  66. branches ;
  67. next     1.5;
  68.  
  69. 1.5
  70. date     87.10.21.11.04.31;  author nelson;  state Exp;
  71. branches ;
  72. next     1.4;
  73.  
  74. 1.4
  75. date     87.08.10.15.11.49;  author nelson;  state Exp;
  76. branches ;
  77. next     1.3;
  78.  
  79. 1.3
  80. date     87.06.01.15.44.00;  author nelson;  state Exp;
  81. branches ;
  82. next     1.2;
  83.  
  84. 1.2
  85. date     86.12.16.13.22.25;  author nelson;  state Exp;
  86. branches ;
  87. next     1.1;
  88.  
  89. 1.1
  90. date     86.07.27.12.53.02;  author nelson;  state Exp;
  91. branches ;
  92. next     ;
  93.  
  94.  
  95. desc
  96. @@
  97.  
  98.  
  99. 1.17
  100. log
  101. @Changes to reflect new OFS file system names.
  102. @
  103. text
  104. @/* 
  105.  * fscheck.h
  106.  *
  107.  *    Types for the file system check program.
  108.  *
  109.  * Copyright (C) 1986 Regents of the University of California
  110.  * All rights reserved.
  111.  *
  112.  * $Header: /sprite/src/cmds/fscheck/RCS/fscheck.h,v 1.16 90/10/10 11:22:14 jhh Exp Locker: mendel $ SPRITE (Berkeley)
  113.  */
  114.  
  115. #ifndef _FSCHECK
  116. #define _FSCHECK
  117.  
  118. #include "disk.h"
  119. #include <sys/types.h>
  120. #include <varargs.h>
  121. #include <stdio.h>
  122. #include <errno.h>
  123. #include <stdlib.h>
  124. #include <time.h>
  125. #include <sys/time.h>
  126.  
  127. /*
  128.  *  fscheck Proc_Exit status codes.
  129.  *     Codes < 0 are hard errors. Codes > 0 are soft errors.
  130.  *
  131.  */
  132. #define EXIT_OK        (char) 0
  133.  
  134. #define EXIT_SOFT_ERROR        (char) 1
  135. #define EXIT_OUT_OF_MEMORY    (char) 2
  136. #define EXIT_NOREBOOT        (char) 3
  137. #define EXIT_REBOOT        (char) 4
  138.  
  139. #define EXIT_HARD_ERROR        (char) -1
  140. #define EXIT_READ_FAILURE    (char) -2
  141. #define EXIT_WRITE_FAILURE    (char) -3
  142. #define EXIT_BAD_ARG        (char) -4
  143. #define EXIT_MORE_MEMORY    (char) -5
  144. #define EXIT_DISK_FULL        (char) -6
  145.  
  146. /*
  147.  * Structure kept for each file descriptor.
  148.  */
  149. typedef struct FdInfo {
  150.     short    flags;        /* Flags defined below. */
  151.     short    origLinkCount;    /* Link count from the file descriptor. */
  152.     short    newLinkCount;    /* Link computed by checkFS. */
  153. } FdInfo;
  154.  
  155. /*
  156.  * Flag values.
  157.  *
  158.  *    IS_A_DIRECTORY    This file is a directory.
  159.  *    FD_REFERENCED    This file is referenced by a directory.
  160.  *    FD_MODIFIED    This file descriptor has been modified.
  161.  *    FD_SEEN        This file descriptor has already been checked.
  162.  *    FD_ALLOCATED    This file descriptor is allocated.    
  163.  *    ON_MOD_LIST    This file descriptor is on the modified list.
  164.  *    FD_UNREADABLE    This file descriptor is in an unreadable sector.
  165.  *    FD_RELOCATE    This file descriptor is in a readable sector in
  166.  *            an unreadable block and is being relocated.
  167.  */
  168. #define    IS_A_DIRECTORY    0x01
  169. #define    FD_REFERENCED    0x02
  170. #define    FD_MODIFIED    0x04
  171. #define    FD_SEEN        0x08
  172. #define    FD_ALLOCATED    0x10
  173. #define    ON_MOD_LIST    0x20
  174. #define    FD_UNREADABLE    0x40
  175. #define    FD_RELOCATE    0x80
  176.  
  177. /*
  178.  * Structure for each element of the list of modified file descriptors.
  179.  */
  180. typedef struct ModListElement {
  181.     List_Links        links;
  182.     int            fdNum;
  183.     Fsdm_FileDescriptor    *fdPtr;
  184. } ModListElement;
  185. extern    List_Links    modListHdr;
  186. #define    modList &modListHdr
  187.  
  188. /*
  189.  * Structure for each element of the list of relocating file descriptors.
  190.  * Note that it looks like a ModListElement with an extra file descriptor
  191.  * number at the end.  It can be inserted into the modList and written
  192.  * in location newFdNum once newFdNum has been assigned.
  193.  */
  194. typedef struct RelocListElement {
  195.     List_Links        links;
  196.     int            newFdNum;
  197.     Fsdm_FileDescriptor    *fdPtr;
  198.     int            origFdNum;
  199. } RelocListElement;
  200. extern    List_Links    relocListHdr;
  201. #define    relocList &relocListHdr
  202.  
  203. typedef enum {
  204.     DIRECT, 
  205.     INDIRECT, 
  206.     DBL_INDIRECT
  207. } BlockIndexType;
  208.  
  209. typedef enum {
  210.     FD, 
  211.     BLOCK, 
  212. } ParentType;
  213.  
  214. /*
  215.  * Structure for each element of the list of file blocks that need to be copied.
  216.  */
  217.  
  218. typedef struct CopyListElement {
  219.     List_Links        links;
  220.     BlockIndexType    blockType;
  221.     short        fragments;
  222.     int            index;
  223.     ParentType        parentType;
  224.     int            parentNum;
  225.     Fsdm_FileDescriptor    *fdPtr;
  226. } CopyListElement;
  227.  
  228. extern    List_Links    copyListHdr;
  229. #define    copyList ©ListHdr
  230.  
  231.  
  232. /*
  233.  * Structure to contain the current state about a block index.
  234.  */
  235.  
  236.  
  237. typedef struct DirIndexInfo {
  238.     FdInfo         *fdInfoPtr;         /* Status info about the file 
  239.                           * descriptor being read. */
  240.     Fsdm_FileDescriptor *fdPtr;                  /* The file descriptor being
  241.                         read. */
  242.     BlockIndexType indexType;             /* Whether chasing direct, 
  243.                         indirect, or doubly indirect 
  244.                         blocks. */
  245.     int         blockNum;             /* Block that is being read, 
  246.                         written, or allocated. */
  247.     int         blockAddr;             /* Address of directory block
  248.                         to read. */
  249.     int         dirOffset;             /* Offset of the directory entry 
  250.                         that we are currently examining 
  251.                         in the directory. */
  252.     char     dirBlock[FS_BLOCK_SIZE];    /* Where directory data is 
  253.                         stored. */
  254.     int         numFrags;             /* Number of fragments stored in
  255.                         the directory entry. */
  256.     int         firstIndex;             /* An index into either the direct
  257.                             block pointers or into an 
  258.                             indirect block. */
  259.     int         secondIndex;             /* An index into a doubly indirect
  260.                             block. */
  261.     char      firstBlock[FS_BLOCK_SIZE];  /* First level indirect block. */
  262.     int         firstBlockNil;             /* The first level block is 
  263.                         empty.*/
  264.     char      secondBlock[FS_BLOCK_SIZE]; /* Second level indirect block. */
  265.     int         secondBlockNil;         /* The second level block 
  266.                         is empty.*/
  267.     int         dirDirty;             /* 1 if the directory block is
  268.                         dirty. */
  269. } DirIndexInfo;
  270.  
  271. extern int    numBlocks;
  272. extern int    numFiles;
  273. extern int    numBadDesc;
  274. extern int    numFrags;
  275. extern int    foundError;
  276. extern int    errorType;
  277. extern int    fdBitmapError;
  278. extern Boolean    tooBig;
  279. extern int    noCopy;
  280. extern int    debug;
  281. extern char    end[];
  282. extern FILE     *outputFile;
  283. extern int    patchHeader;
  284. extern int    writeDisk;
  285. extern int    verbose;
  286. extern int    silent;
  287. extern int    clearDomainNumber;
  288. extern int    recoveryCheck;
  289. extern int    badBlockInit;
  290. extern int    patchRoot;
  291. extern int    flushBuffer;
  292. extern int    maxHeapSize;
  293. extern int    bufferSize;
  294. extern int    heapSize;
  295. extern int    lastErrorFD;
  296. extern int    num1KBlocks;
  297. extern int    bytesPerCylinder;
  298. extern List_Links    modListHdr;
  299. extern List_Links    relocListHdr;
  300. extern unsigned char *fdBitmapPtr;
  301. extern unsigned char *cylBitmapPtr;
  302. extern unsigned char bitmasks[];
  303. extern int    rawOutput;
  304. extern int    attached;
  305. extern int    outputFileNum;
  306. extern char    *outputFileName;
  307. extern Ofs_DomainHeader  *domainPtr;
  308. extern int        partFID;
  309. extern int    bitmapVerbose;
  310. extern int    fixCount;
  311. extern int    numReboot;
  312. extern int    clearFixCount;
  313. extern int    blockToFind;
  314. extern int    fileToPrint;
  315. extern int    setCheckedBit;
  316.  
  317. extern int Output();    
  318. extern void OutputPerror();    
  319. extern void WriteOutputFile();    
  320. extern int CloseOutputFile();    
  321. extern void ExitHandler();
  322. extern char *sbrk();
  323. extern void ClearFd();
  324. extern void UnmarkBitmap();
  325. extern int MarkBitmap();
  326. extern void AddToCopyList();
  327.  
  328. /*
  329.  * Macro to get a pointer into the bit map for a particular block.
  330.  */
  331. #define BlockToCylinder(domainPtr, blockNum) \
  332.     (blockNum) / (domainPtr)->geometry.blocksPerCylinder
  333.  
  334. #define GetBitmapPtr(domainPtr, bitmapPtr, blockNum) \
  335.   &((bitmapPtr)[BlockToCylinder(domainPtr, blockNum) * \
  336.   bytesPerCylinder + (blockNum) % (domainPtr)->geometry.blocksPerCylinder / 2])
  337.  
  338. /*
  339.  * Macros to convirt physical block numbers to virtual block numbers. All direct
  340.  * blocks are virtual, indirect blocks are physical.
  341.  */
  342. #define VirtToPhys(domainPtr,blockNum) \
  343.     ((blockNum) + (domainPtr)->dataOffset * FS_FRAGMENTS_PER_BLOCK)
  344.  
  345. #define PhysToVirt(domainPtr,blockNum) \
  346.     ((blockNum) - (domainPtr)->dataOffset * FS_FRAGMENTS_PER_BLOCK)
  347.  
  348. #define MarkFDBitmap(num,bitmapPtr) \
  349.     (bitmapPtr)[(num) >> 3] |= (1 << (7 -((num)  & 7))) 
  350.  
  351. #define UnmarkFDBitmap(num,bitmapPtr) \
  352.     (bitmapPtr)[(num) >> 3] &= ~(1 << (7 -((num)  & 7))) 
  353.  
  354. /*
  355.  * Number of file descriptors in a sector, if we have to go through
  356.  * the sectors individually.
  357.  */
  358. #define FILE_DESC_PER_SECTOR (FSDM_FILE_DESC_PER_BLOCK / DISK_SECTORS_PER_BLOCK)
  359.  
  360.  
  361.  
  362. #define Alloc(ptr,type,number) AllocByte((ptr),type,sizeof(type) * (number))
  363.  
  364. #define AllocByte(ptr,type,numBytes) { \
  365.     int oldHeapSize = heapSize; \
  366.     (ptr) = (type *) malloc((unsigned) (numBytes)); \
  367.     heapSize = (int) (sbrk(0) - (char *) end); \
  368.     if ((heapSize != oldHeapSize) && (debug)) {\
  369.         Output(stderr,"Heapsize now %d.\n",heapSize); \
  370.     }\
  371.     if ((maxHeapSize > 0) && (heapSize > maxHeapSize) && (!tooBig)) { \
  372.         tooBig = TRUE; \
  373.         Output(stderr,"Heap limit exceeded.\n"); \
  374.         (ptr) = NULL; \
  375.         foundError = 1;\
  376.         errorType = EXIT_OUT_OF_MEMORY;\
  377.     } }
  378.  
  379. #define min(a,b) (((a) < (b)) ? (a) : (b) )
  380.  
  381. #endif _FSCHECK
  382. @
  383.  
  384.  
  385. 1.16
  386. log
  387. @now can do raw output on any partition, fixed bug with ".."
  388. @
  389. text
  390. @d9 1
  391. a9 1
  392.  * $Header: /sprite/src/cmds/fscheck/RCS/fscheck.h,v 1.15 90/05/01 15:36:45 jhh Exp $ SPRITE (Berkeley)
  393. d204 1
  394. a204 1
  395. extern Fsdm_DomainHeader  *domainPtr;
  396. @
  397.  
  398.  
  399. 1.15
  400. log
  401. @ported to new Disk library
  402. @
  403. text
  404. @d9 1
  405. a9 1
  406.  * $Header: /sprite/src/cmds/fscheck/RCS/fscheck.h,v 1.14 90/02/14 15:55:32 jhh Exp Locker: jhh $ SPRITE (Berkeley)
  407. d26 1
  408. a26 2
  409.  *     Codes < 0 are hard errors. Codes > 0 are soft errors that require
  410.  *    rerunning the program.
  411. d34 1
  412. d200 2
  413. a201 1
  414. extern int    rootPart;
  415. @
  416.  
  417.  
  418. 1.14
  419. log
  420. @support for no recheck on reboot
  421. @
  422. text
  423. @d9 1
  424. a9 1
  425.  * $Header: /a/newcmds/fscheck/RCS/fscheck.h,v 1.13 89/10/03 11:09:05 jhh Exp $ SPRITE (Berkeley)
  426. d15 1
  427. a15 1
  428. #include "diskUtils.h"
  429. @
  430.  
  431.  
  432. 1.13
  433. log
  434. @new scsi disk mapping
  435. @
  436. text
  437. @d9 1
  438. a9 1
  439.  * $Header: /a/newcmds/fscheck/RCS/fscheck.h,v 1.12 89/09/25 16:41:17 jhh Exp Locker: jhh $ SPRITE (Berkeley)
  440. d211 1
  441. @
  442.  
  443.  
  444. 1.12
  445. log
  446. @Uses new fs module structure
  447. @
  448. text
  449. @d9 1
  450. a9 1
  451.  * $Header: /a/newcmds/fscheck/RCS/fscheck.h,v 1.11 89/06/21 23:56:07 jhh Exp Locker: jhh $ SPRITE (Berkeley)
  452. d209 2
  453. @
  454.  
  455.  
  456. 1.11
  457. log
  458. @Various bug fixes
  459. @
  460. text
  461. @d9 1
  462. a9 1
  463.  * $Header: /a/newcmds/fscheck/RCS/fscheck.h,v 1.10 89/02/28 12:22:36 jhh Exp $ SPRITE (Berkeley)
  464. d80 1
  465. a80 1
  466.     FsFileDescriptor    *fdPtr;
  467. d94 1
  468. a94 1
  469.     FsFileDescriptor    *fdPtr;
  470. d122 1
  471. a122 1
  472.     FsFileDescriptor    *fdPtr;
  473. d137 1
  474. a137 1
  475.     FsFileDescriptor *fdPtr;                  /* The file descriptor being
  476. d203 1
  477. a203 1
  478. extern FsDomainHeader  *domainPtr;
  479. d251 1
  480. a251 1
  481. #define FILE_DESC_PER_SECTOR (FS_FILE_DESC_PER_BLOCK / DISK_SECTORS_PER_BLOCK)
  482. @
  483.  
  484.  
  485. 1.10
  486. log
  487. @Converted to new C library, added lots of new functionality
  488. @
  489. text
  490. @d9 1
  491. a9 1
  492.  * $Header: /a/newcmds/fscheck/RCS/fscheck.h,v 1.9 88/12/04 21:34:31 nelson Exp $ SPRITE (Berkeley)
  493. d30 1
  494. a30 1
  495. #define EXIT_OK        0
  496. d32 10
  497. a41 2
  498. #define EXIT_SOFT_ERROR        1
  499. #define EXIT_OUT_OF_MEMORY    2
  500. a42 7
  501. #define EXIT_HARD_ERROR        -1
  502. #define EXIT_READ_FAILURE    -2
  503. #define EXIT_WRITE_FAILURE    -3
  504. #define EXIT_BAD_ARG        -4
  505. #define EXIT_MORE_MEMORY    -5
  506. #define EXIT_DISK_FULL        -6
  507.  
  508. d205 4
  509. a208 1
  510.  
  511. @
  512.  
  513.  
  514. 1.9
  515. log
  516. @Converted over to new C library but not fully tested yet.
  517. @
  518. text
  519. @d9 1
  520. a9 1
  521.  * $Header: checkFS.h,v 1.8 88/07/19 11:47:51 douglis Exp $ SPRITE (Berkeley)
  522. d16 7
  523. a23 1
  524.  
  525. d25 4
  526. a28 4
  527.  * checkFS Proc_Exit status codes.
  528.  *    EXIT_OK        No errors were encountered
  529.  *    EXIT_SOFT_ERR    Correctable errors were found and fixed
  530.  *    EXIT_HARD_ERR    Uncorrectable errors were found, bad arguments, etc.
  531. a30 2
  532. #define EXIT_SOFT_ERR    1
  533. #define EXIT_HARD_ERR    -1
  534. d32 10
  535. d79 1
  536. a79 1
  537.     FsFileDescriptor    fd;
  538. d93 1
  539. a93 1
  540.     FsFileDescriptor    fd;
  541. a98 4
  542. /*
  543.  * Structure to contain the current state about a block index.
  544.  */
  545.  
  546. d105 28
  547. d167 102
  548. a268 1
  549. extern    Boolean    foundError;
  550. @
  551.  
  552.  
  553. 1.8
  554. log
  555. @Added ability to salvage and relocate file descriptors in unreadable
  556. blocks and to mark those blocks as unuseable (temporarily -- if readable
  557. again later, they will be reclaimed).
  558. @
  559. text
  560. @d2 1
  561. a2 1
  562.  * checkFS.h
  563. d9 1
  564. a9 1
  565.  * $Header: checkFS.h,v 1.7 88/06/02 13:01:58 brent Exp $ SPRITE (Berkeley)
  566. d12 2
  567. a13 2
  568. #ifndef _CHECKFS
  569. #define _CHECKFS
  570. a14 1
  571. #include "sprite.h"
  572. a85 6
  573.  * Return statuses for searching directories.
  574.  */
  575.  
  576. #define    DIR_HOLE          0x80010001
  577.  
  578. /*
  579. d120 1
  580. a120 1
  581.     Boolean     firstBlockNil;             /* The first level block is 
  582. d123 1
  583. a123 1
  584.     Boolean     secondBlockNil;         /* The second level block 
  585. d125 1
  586. a125 1
  587.     Boolean     dirDirty;             /* TRUE if the directory block is
  588. d131 1
  589. a131 1
  590. #endif _CHECKFS
  591. @
  592.  
  593.  
  594. 1.7
  595. log
  596. @Fixed include
  597. @
  598. text
  599. @d9 1
  600. a9 1
  601.  * $Header: checkFS.h,v 1.6 88/06/02 12:58:19 brent Exp $ SPRITE (Berkeley)
  602. d47 3
  603. d57 2
  604. d70 15
  605. @
  606.  
  607.  
  608. 1.6
  609. log
  610. @Added exit status codes
  611. @
  612. text
  613. @d9 1
  614. a9 1
  615.  * $Header: checkFS.h,v 1.5 87/10/21 11:04:31 nelson Exp $ SPRITE (Berkeley)
  616. d16 1
  617. a16 1
  618. #include "fsDisk.h"
  619. @
  620.  
  621.  
  622. 1.5
  623. log
  624. @Set error status flag on error.
  625. @
  626. text
  627. @d9 1
  628. a9 1
  629.  * $Header: checkFS.h,v 1.4 87/08/10 15:11:49 nelson Exp $ SPRITE (Berkeley)
  630. d17 11
  631. @
  632.  
  633.  
  634. 1.4
  635. log
  636. @Changed to handle new method that requires a lot less memory.
  637. @
  638. text
  639. @d9 1
  640. a9 1
  641.  * $Header: checkFS.h,v 1.3 87/06/01 15:44:00 nelson Exp $ SPRITE (Berkeley)
  642. d104 2
  643. @
  644.  
  645.  
  646. 1.3
  647. log
  648. @Deleted unneeded fields from directory scanning structure.
  649. @
  650. text
  651. @d9 1
  652. a9 1
  653.  * $Header: checkFS.h,v 1.2 86/12/16 13:22:25 nelson Exp $ SPRITE (Berkeley)
  654. d18 3
  655. d22 3
  656. a24 5
  657.     FsFileDescriptor fileDesc;
  658.     int             parentLinkCount;
  659.     int             linkCount;
  660.     int             blockCount;
  661.     Boolean         seen;
  662. d28 28
  663. d72 4
  664. a75 2
  665.     FdInfo       *descInfoPtr;         /* The file descriptor that is 
  666.                         being read. */
  667. @
  668.  
  669.  
  670. 1.2
  671. log
  672. @Fixed various bugs and enhanced error statements.
  673. @
  674. text
  675. @d9 1
  676. a9 1
  677.  * $Header: checkFS.h,v 1.1 86/07/27 12:53:02 nelson Exp $ SPRITE (Berkeley)
  678. a42 2
  679.     int           partFID;             /* File id for the partition. */
  680.     FsDomainHeader *domainPtr;             /* The domain. */
  681. @
  682.  
  683.  
  684. 1.1
  685. log
  686. @Initial revision
  687. @
  688. text
  689. @d9 1
  690. a9 1
  691.  * $Header$ SPRITE (Berkeley)
  692. d20 1
  693. @
  694.